PSCI: Validate non secure entrypoint on ARM platforms
authorSoby Mathew <[email protected]>
Wed, 15 Jul 2015 12:36:24 +0000 (13:36 +0100)
committerAchin Gupta <[email protected]>
Thu, 13 Aug 2015 22:48:07 +0000 (23:48 +0100)
This patch implements the platform power managment handler to verify
non secure entrypoint for ARM platforms. The handler ensures that the
entry point specified by the normal world during CPU_SUSPEND, CPU_ON
or SYSTEM_SUSPEND PSCI API is a valid address within the non secure
DRAM.

Change-Id: I4795452df99f67a24682b22f0e0967175c1de429

include/plat/arm/common/plat_arm.h
plat/arm/board/fvp/fvp_pm.c
plat/arm/common/arm_pm.c
plat/arm/css/common/css_pm.c

index 56b5eda573ab9802f803f3617c7f4bc6aeb2d943..823212cb3a356f0420c85ef8b3fd9664961a6a23 100644 (file)
@@ -190,6 +190,7 @@ void arm_tzc_setup(void);
 /* PM utility functions */
 int arm_validate_power_state(unsigned int power_state,
                            psci_power_state_t *req_state);
+int arm_validate_ns_entrypoint(uintptr_t entrypoint);
 
 /* Topology utility function */
 int arm_check_mpidr(u_register_t mpidr);
index 8be51054b22dc117d79383a287c04330695c3294..9d6ab9ce6fee2f01805a4f627b78f926b2ca1ae8 100644 (file)
@@ -304,7 +304,8 @@ static const plat_psci_ops_t fvp_plat_psci_ops = {
        .pwr_domain_suspend_finish = fvp_pwr_domain_suspend_finish,
        .system_off = fvp_system_off,
        .system_reset = fvp_system_reset,
-       .validate_power_state = arm_validate_power_state
+       .validate_power_state = arm_validate_power_state,
+       .validate_ns_entrypoint = arm_validate_ns_entrypoint
 };
 
 /*******************************************************************************
index 71fbf9f11f7d8cc95b23cebe351ae2cbc363d2ba..b2251700f0eb32ebf962946ee8618173cc350583 100644 (file)
@@ -29,6 +29,7 @@
  */
 
 #include <arch_helpers.h>
+#include <arm_def.h>
 #include <assert.h>
 #include <errno.h>
 #include <plat_arm.h>
@@ -123,3 +124,23 @@ int arm_validate_power_state(unsigned int power_state,
        return PSCI_E_SUCCESS;
 }
 #endif /* __ARM_RECOM_STATE_ID_ENC__ */
+
+/*******************************************************************************
+ * ARM standard platform handler called to check the validity of the non secure
+ * entrypoint.
+ ******************************************************************************/
+int arm_validate_ns_entrypoint(uintptr_t entrypoint)
+{
+       /*
+        * Check if the non secure entrypoint lies within the non
+        * secure DRAM.
+        */
+       if ((entrypoint >= ARM_NS_DRAM1_BASE) && (entrypoint <
+                       (ARM_NS_DRAM1_BASE + ARM_NS_DRAM1_SIZE)))
+               return PSCI_E_SUCCESS;
+       if ((entrypoint >= ARM_DRAM2_BASE) && (entrypoint <
+                       (ARM_DRAM2_BASE + ARM_DRAM2_SIZE)))
+               return PSCI_E_SUCCESS;
+
+       return PSCI_E_INVALID_ADDRESS;
+}
index 435ed2aa660c94d00fef13d57d76ba889184bcee..cc64bf8bfcc776f0c06b0bda7b02d48f9f2d4177 100644 (file)
@@ -267,7 +267,8 @@ static const plat_psci_ops_t css_ops = {
        .pwr_domain_suspend_finish      = css_pwr_domain_suspend_finish,
        .system_off             = css_system_off,
        .system_reset           = css_system_reset,
-       .validate_power_state   = arm_validate_power_state
+       .validate_power_state   = arm_validate_power_state,
+       .validate_ns_entrypoint = arm_validate_ns_entrypoint
 };
 
 /*******************************************************************************